package com.tind.wyf.baselib.base.nav;

import androidx.annotation.NonNull;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 打开跳转到装载有fragment的界面
 * 数据
 */
public class FragmentBuilder implements Serializable {
    private int[] icons;//图标
    private String[] title;//标题
    private String[] titleBar;//tabbar文字
    private List<Class> clx = new ArrayList<>();//fragment类集合

    public int[] getIcons() {
        return icons;
    }

    public FragmentBuilder setIcons(int[] icons) {
        this.icons = icons;
        return this;
    }

    public String[] getTitle() {
        return title;
    }

    public FragmentBuilder setTitle(String[] title) {
        this.title = title;
        return this;
    }


    public List<Class> getClx() {
        return clx;
    }

    /**
     *  设置相同
     * @param clx
     * @return
     */
    public FragmentBuilder setClx(Class clx) {
        clearClx(this.clx);
        for (int i = 0; i < titleBar.length; i++) {
            this.clx.add(clx);
        }
        return this;
    }

    public FragmentBuilder setClx(List<Class> clx) {
        this.clx = clx;
        return this;
    }

    public FragmentBuilder setClx(int position, Class clx) {
        this.clx.set(position, clx);
        return this;
    }
    public FragmentBuilder addClx(int position, Class clx) {
        this.clx.set(position, clx);
        return this;
    }
    public FragmentBuilder remove(Class clx) {
        this.clx.remove(clx);
        return this;
    }

    public FragmentBuilder remove(int position) {
        this.clx.remove(position);
        return this;
    }

    public String[] getTitleBar() {
        return titleBar;
    }

    /**
     *
     * @param titleBar
     * @return
     */
    public FragmentBuilder setTitleBar(@NonNull String[] titleBar) {
        this.titleBar = titleBar;
        return this;
    }

    private FragmentBuilder clearClx(List<Class> clx) {
        if (clx != null)
            this.clx.clear();
        return this;
    }

    public static FragmentBuilder buidler() {
        return new FragmentBuilder();
    }
}
